<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<div id="d" style="height: 200px; width: 200px; border: 1px solid red;">
			xxx
		</div>
		<div id="d2" style="height: 200px; width: 200px; border: 1px solid red;">
			
		</div>
		<input type="button" value="获得div高度" onclick="showDiv()" />
		<input type="button" value="给div添加高度10px" onclick="inc()" />
	</body>
	<script>
		function showDiv(){
			var d=document.getElementById("d2");
			var h=(document.defaultView.getComputedStyle(d,null)||d.currentStyle).height;
			alert("高度是："+h);
		}
		function inc(){
			var a=document.getElementById("d2");
			var h=(document.defaultView.getComputedStyle(a,null)||a.currentStyle).height;
			var b=parseInt(h)+20;
			var c=b+"px";
		a.style.height=c;
		}
	</script>
</html>
